home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / scbench.arc / SCBIGWT.C < prev    next >
Text File  |  1980-01-01  |  1KB  |  60 lines

  1. /*
  2. ** BYTE Small-C  Disk I/O benchmark
  3. ** Version 1 for 8088/8086/80286/80386
  4. ** Feb. 17, 1988
  5. ** Written in BYTE Small-C
  6. ** Based on Small-C by J.E. Hendrix
  7. **
  8. ** Test times the writing of a 1 million byte file
  9. ** Requires support routines gtime and calctim.
  10. */
  11.  
  12. #include stdio.h
  13.  
  14. #define BUFSIZ 10000    /* Size of write buffer */
  15. #define LOOPS  100    /* number of times to write BUFSIZ characters to get
  16.                1000000 byte file. */
  17. char *wbuff;        /* Pointer to write buffer */
  18. int tblock[4];        /* Timer block */
  19.  
  20. main()
  21. {
  22.     int i;
  23.     int fd;        /* File handle */
  24.  
  25.     /* Announce program */
  26.     printf("BYTE Large File Write Benchmark\n\n");
  27.  
  28.     /* Allocate space for the write if possible*/
  29.     wbuff=malloc(BUFSIZ);
  30.     if(wbuff==NULL) {
  31.         printf("Not enough memory for wbuff\n");
  32.         exit(0);
  33.     }
  34.  
  35.     /* Fill up the buffer */
  36.     for(i=0;i<BUFSIZ;++i)
  37.         wbuff[i]='A';
  38.  
  39.     /* Open the file */
  40.     fd=fopen("BIGFILE.DAT","w");
  41.  
  42.     /* Turn on the timer */
  43.     gtime(tblock);
  44.  
  45.     /* Loop and write the file */
  46.     for(i=0;i<LOOPS;++i)
  47.         write(fd,wbuff,BUFSIZ);
  48.  
  49.     /* Turn off timer and close file */
  50.     calctim(tblock);
  51.     fclose(fd);
  52.  
  53.     /* Report results */
  54.     printf("Results: (HH:MM:SS:1/100ths)\n");
  55.     printf("Time to write file: %d:%d:%d:%d\n",tblock[0],tblock[1],
  56.      tblock[2],tblock[3]);
  57.  
  58.     exit(0);
  59.  
  60. }